package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.domain.FilterList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MCourseMapper;
import com.ruoyi.system.domain.MCourse;
import com.ruoyi.system.service.IMCourseService;

/**
 * 课程套餐Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-25
 */
@Service
public class MCourseServiceImpl implements IMCourseService 
{
    @Autowired
    private MCourseMapper mCourseMapper;

    @Autowired
    private RedisCache redisCache;

    /**
     * 查询课程套餐
     * 
     * @param courseid 课程套餐主键
     * @return 课程套餐
     */
    @Override
    public MCourse selectMCourseByCourseid(Long courseid)
    {
        return mCourseMapper.selectMCourseByCourseid(courseid);
    }

    /**
     * 查询课程套餐列表
     * 
     * @param mCourse 课程套餐
     * @return 课程套餐
     */
    @Override
    public List<MCourse> selectMCourseList(MCourse mCourse)
    {
        return mCourseMapper.selectMCourseList(mCourse);
    }

    /**
     * 新增课程套餐
     * 
     * @param mCourse 课程套餐
     * @return 结果
     */
    @Override
    public int insertMCourse(MCourse mCourse)
    {

       int i= mCourseMapper.insertMCourse(mCourse);
        List<FilterList> filterList = mCourseMapper.selectFiterList();

        redisCache.setCacheObjectNoLimit("filterList",filterList);
        return  i;
    }

    /**
     * 修改课程套餐
     * 
     * @param mCourse 课程套餐
     * @return 结果
     */
    @Override
    public int updateMCourse(MCourse mCourse)
    {
        return mCourseMapper.updateMCourse(mCourse);
    }

    /**
     * 批量删除课程套餐
     * 
     * @param courseids 需要删除的课程套餐主键
     * @return 结果
     */
    @Override
    public int deleteMCourseByCourseids(Long[] courseids)
    {
        return mCourseMapper.deleteMCourseByCourseids(courseids);
    }

    /**
     * 删除课程套餐信息
     * 
     * @param courseid 课程套餐主键
     * @return 结果
     */
    @Override
    public int deleteMCourseByCourseid(Long courseid)
    {
        return mCourseMapper.deleteMCourseByCourseid(courseid);
    }
}
